package com.leeda.dockerdemo.controller;

import com.leeda.dockerdemo.dao.UserRepository;
import com.leeda.dockerdemo.domain.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * 接受请求
 */

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserRepository userRepository;

    @RequestMapping("/getUserById")
    public UserInfo getUserById(String id){
        System.out.println("id==="+id);
        Optional<UserInfo> byId = userRepository.findById(Integer.parseInt(id));
        UserInfo userInfo = byId.get();
        System.out.println(userInfo.toString());
        return userInfo;
    }


}
